package cate.common.table.activity.destinygate.row;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class DestinyGateChapterRow extends ERow {
    @NoteField(value = "原型ID")
    public int heroId;

    @NoteField(value = "关卡ID")
    public int level;

    @NoteField(value = "前置关卡ID")
    public int levelBefore;

    @NoteField(value = "首通奖励")
    public String firstRewardStr;

    @NoteField(value = "挑战需求星级")
    public String challengeConf;

    @NoteField(value = "最大上阵人数")
    public int max;

    @NoteField(value = "怪物实例")
    public String dynInsCode;

    @NoteField(value = "星级挑战ID")
    public String starChallengeStr;

    @NoteField(value = "成就挑战ID")
    public String achieveChallengeStr;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("ID",0);
        this.heroId = xrw.getInteger("原型ID",0);
        this.level = xrw.getInteger("关卡ID", 1);
        this.levelBefore = xrw.getInteger("前置关卡ID", 0);
        this.firstRewardStr = xrw.getString("首通奖励");
        this.challengeConf = xrw.getString("挑战需求星级");
        this.max = xrw.getInteger("最大上阵人数",0);
        this.dynInsCode = xrw.getString("怪物实例");
        this.starChallengeStr = xrw.getString("星级挑战ID");
        this.achieveChallengeStr = xrw.getString("成就挑战ID");
    }

    public List<Integer> challengeIds;

    public List<Integer> achieveIds;

    @Override
    public void decode() {
        challengeIds = new ArrayList<>();
        if (StringUtils.isNotBlank(starChallengeStr)) {
            String[] split = starChallengeStr.split("#");
            for (String str : split) {
                challengeIds.add(Integer.parseInt(str));
            }
        }
        achieveIds = new ArrayList<>();
        if (StringUtils.isNotBlank(achieveChallengeStr)) {
            String[] split = achieveChallengeStr.split("#");
            for (String str : split) {
                achieveIds.add(Integer.parseInt(str));
            }
        }
    }

}
